<?php
    @header("Content-Type:text/html;charset=utf-8");    // 配置php文件返回的 文本类型 编码(适应低版本)         => php 向 前端 返回的数据类型

    @include_once("../../php/conn.php");      //引入公共的php 

    if(!$conn) {
        exit("数据库连接失败");
    } 

    $user = $_POST["user"];
    $pwd = $_POST["pwd"];
    $email = $_POST["email"];
    $phone = $_POST["phone"];
    
    if(!($user && $pwd & $email && $phone)) {
        $obj = array();
        $obj["status"] = false;
        $obj["msg"] = "请传入完整参数";
        exit(json_encode($obj));
    }

// 注意
    // 1.引号不能删
    // 2.复制时不能有空格
    $insert = "insert into `register`(user,pwd,email,phone) value ('$user','$pwd','$email','$phone')"; 
    $result = mysqli_query($conn,$insert);
    $rows = mysqli_affected_rows($conn);    
    
    
    $obj = array();
    if($rows > 0) {
        $obj["status"] = true;
        $obj["msg"] = "新增成功";  
    } else {
        $obj["status"] = false;
        $obj["msg"] = "新增失败";
        $obj["sql"] = $insert;
    }
    echo json_encode($obj);
     
    




?>
